/*
 * =====================================================================================
 *
 *       Filename:  count1bits.cpp
 *
 *    Description:  counting the number of 1 bits in a 32bits integer. Solve this 
 *					problem with more than one ways.
 *
 *        Version:  1.0
 *        Created:  12-04-09 11:28:21 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */


#include <stdlib.h>
#include <iostream>

using namespace std;

int countones1(int value){

	int retValue=0;

	for(int i=0; i<32; ++i){
		
		if((value & 1) == 1)
			retValue++;

		value>>=1;
	}

	return retValue;
}

int countones2(int value){
	int retValue=0;

	for(int i=0; i<32; ++i){
		
		if((value%2)==1)
			retValue++;

		value >>= 1;

	}

	return retValue;
}

int main(){
	cout << countones2(7) << endl;

	return 1;
}
